package com.example.activity;

import com.example.smart_home.R;
import com.example.util.ShowHandle;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class DefenseActivity extends Activity
  implements View.OnClickListener
{
  private static final int CONNECT_FAIL = 1;
 // private static final int CONNECT_SUCCESS;
  private DefenseActivity context;
  private ListView lvDefense;
  private Handler mHandler = new Handler()
  {
    public void handleMessage(Message paramAnonymousMessage)
    {
      switch (paramAnonymousMessage.what)
      {
      default:
        return;
      case 0:
        Toast.makeText(DefenseActivity.this.context, DefenseActivity.this.context.getResources().getString(2131296337), 0).show();
        char[] arrayOfChar = ((String)paramAnonymousMessage.obj).split("-")[2].toCharArray();
      //  DefenseActivity.access$102(DefenseActivity.this, new ShowHandle(DefenseActivity.this.context, "it"));
        DefenseActivity.this.showHandle.OpenDb();
      //  DefenseItemAdapter localDefenseItemAdapter = new DefenseItemAdapter(DefenseActivity.this.context, DefenseActivity.this.showHandle.getSensorInList(), arrayOfChar);
        DefenseActivity.this.showHandle.CloseDb();
       // DefenseActivity.this.lvDefense.setAdapter(localDefenseItemAdapter);
        return;
      case 1:
      }
      Toast.makeText(DefenseActivity.this.context, DefenseActivity.this.context.getResources().getString(2131296335), 0).show();
    }
  };
  private ShowHandle showHandle;

  private void bindListener()
  {
    findViewById(2131165292).setOnClickListener(this);
  }

  private void initView()
  {
    ((TextView)findViewById(2131165294)).setText(2131296640);
    findViewById(2131165293).setVisibility(8);
    this.lvDefense = ((ListView)findViewById(2131165263));
  }

  /*private void readEventSW315M()
  {
    new Thread(new Runnable()
    {
      public void run()
      {
        if ((SocketClient.Current != null) && (SocketClient.Current.isConnect(DefenseActivity.this.context)))
        {
          String str = SocketClient.Current.exchangeMessage("EVENT-SW315M-READ");
          if (!TextUtils.isEmpty(str))
          {
            Message localMessage = new Message();
            localMessage.what = 0;
            localMessage.obj = str;
            DefenseActivity.this.mHandler.sendMessage(localMessage);
          }
        }
        else
        {
          return;
        }
        DefenseActivity.this.mHandler.sendEmptyMessage(1);
      }
    }).start();
  }*/

  public void onClick(View paramView)
  {
    switch (paramView.getId())
    {
    default:
      return;
    case 2131165292:
    }
   // MyAudioManager.spPlaySound(0, false);
    finish();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.defense);
    this.context = this;
    initView();
    bindListener();
    //readEventSW315M();
  }


}

